<?php

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */
 $root = '../';
$title = 'WBCMS - wap blogs CMS';

include('../system/core.php');
include('../system/head.php');

$action=htmlspecialchars(trim($_GET['a']));

switch ($action){

default:
$pr=$_GET['id'];  
$namecat = mysql_query("SELECT * FROM `cat` WHERE `id` = '$pr' LIMIT 1");
$nc = mysql_fetch_assoc($namecat);

echo '<div class="title">'.$nc['name'].'</div>';

   // echo '<div id="imenu">';

//$post=mysql_query("SELECT * FROM `posts` WHERE `catid` = '$pr' LIMIT $kmess");
$posts=mysql_query("SELECT * FROM `posts` WHERE `catid` = '$pr'");

    //Моя навигация
    $page = (isset($_GET['p'])) ? intval($_GET['p']) : 1 ; 
    $allpage = ceil(mysql_num_rows($posts)/$kmess);
    $start = $page*$kmess - $kmess; 



if(!mysql_num_rows($posts)){
    echo '<div class="info">'.$lang['rubric'].'</div>';
if($user['rights'] == 1) echo '<div class="info"><a href="../adm.php?a=add_post">'.$lang['add'].'</a></div>';
        
        }else{
          $post=mysql_query("SELECT * FROM `posts` WHERE `catid` = '$pr' LIMIT $start,$kmess");
while($row=mysql_fetch_assoc($post)){
    
    echo '<div class="small"><a class="url" href="../posts/index.php?id='.$row['id'].'">'.$row['name'].'</a></div>';
    
    };
    $total = mysql_num_rows($posts);
    if($total>$kmess){
    echo '<p>';
    functions::navigation($allpage,"index.php?id=".$pr."&amp;p={p}",1);  
echo '</p>';}
    
    
    //echo '</div>';//imenu
    
        echo '<div class="title">'.$lang['total'].': '.$total.'';
    if($rights == 1){
        echo ' | <a href="../adm.php?a=add_post">'.$lang['add'].'</a></div>';
    }else echo '</div>';
        
        
            }
    
    echo '</div>';



break;


}

$title = "$nc[name]"; //Титл для низа страницы, для СЕО оптимизации желательно укзаывать

include('../system/foot.php');

/**
 * @author FROSTY (valik619)
 * @site nadmad.ru
 * @mail valik619@inbox.ru
 */

?>